package com.lijin.study.java.other;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.Random;
import java.util.regex.Pattern;


public class Test {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("MC59609940110321_BOC_GNETE")), "GBK"));
		String pattern = "^0{79}\\d{14}0{21}\\d{27}0{110}";
		String line = br.readLine();
		while (line != null) {
			if (line.trim().length() == 0 || Pattern.matches(pattern, line)) {
				System.out.println(line);
				continue;
			}
			
			byte[] bytes = line.getBytes("GBK");
			System.out.println("月份：" + new String(bytes, 93, 6));
			line = br.readLine();
		}
		
		String st = "123123,asdaaf,2123123";
		System.out.println(st.split(",").length);
		
//		BufferedWriter bwr = new BufferedWriter(new FileWriter(new File("TARGET")));
//		int c = 0;
//		while (true) {
//			bwr.write("Line Number is :" + c);
//			if (c ++ == 20) {
//				break;
//			}
//			bwr.newLine();
//		}
//		bwr.close();
//		
//		File f = new File("TARGET");
//		System.out.println(f.getName());
//		System.out.println(f.getPath());
//		System.out.println(f.getParent());
//		System.out.println(f.getAbsolutePath());
//		System.out.println(f.getCanonicalPath());
//		System.out.println(f.getCanonicalFile());
//		System.out.println(f.getAbsoluteFile());
//		System.out.println(File.separator);
//		System.out.println(f.getParentFile().getAbsolutePath() + File.separator);
		
		String sts[] = "lijin".split(",");
		System.out.println("changdu -- >" + sts.length);
		
		System.out.println("------");
//		System.out.println(Integer.valueOf("   "));
//		System.out.println(Integer.valueOf(null));
		
		StringBuilder sb = new StringBuilder();
		System.out.println("-----TTT-----");
		System.out.println(sb.toString());
		System.out.println(sb.toString().length());
		
//		System.out.println(arrToStr(new String[] {"lijin", "1010", "1040"}));
		
		String n = "李劲11";
		System.out.println(n);
		System.out.println(n.length());
		System.out.println(n.getBytes().length);
		System.out.println(n.getBytes("GBK").length);
		System.out.println(new String(n.getBytes("GBK")));
		
		System.out.println("xxxxxxxxxxxxxxx");
		String sss = "20110222 19:06:01";
		System.out.println(sss);
		System.out.println(sss.replace(":", "").replace(" ", "").substring(2));
		
		BigDecimal b = BigDecimal.valueOf(100000000);
		System.out.println(b.toString());
		System.out.println(b.movePointLeft(2).toString().length());

		for (int c = 0; c < 100; c ++) {
			int randInt = 0;
			Random rand = new Random();
			int[] array = {0, 1, 2, 3, 4, 5, 2, 3, 4, 1};
			for (int i = 9; i > 1; i--) {
				int index = rand.nextInt(i);
				int tmp = array[index];
				array[index] = array[i - 1];
				array[i - 1] = tmp;
			}
			for (int i = 0; i < 4; i++) {
				randInt = randInt * 10 + array[i];
			}
			System.out.println("计算出的随机数为:" + randInt);
		}
	}
	
	private static String arrToStr(String[] strArr) {
		StringBuilder result = new StringBuilder();
		if (strArr != null) {
			for (int i = 0; i < strArr.length; i ++) {
				result.append(strArr[i]);
				if (i < strArr.length - 1) {
					result.append(",");
				}
			}
		}
		return result.toString();
	}
}
